// P2p body

import QtQuick 2.6
import QtQuick.Layouts 1.1

import "../../Base/UiBase"
import "../../Base/Config"
import Code 1.0
import Cpp.Request 1.0 as Request

import "Teachers" as Teachers

Item {
    Component.onCompleted: {
        teacherGroupsFetcher.fetch(0, 10)
    }

    ListView {
        anchors.fill: parent
        z: -1
        spacing: Size.elementInterval
        delegate: ImageButton {
            width: 720 * Size.ratio
            height: 300 * Size.ratio
            source: model.image
            onClicked: {
                loader.active = true
                loader.item.teacherId = model.identity
                loader.item.visible = true
            }
        }
        model: listmodel
    }
    Loader {
        id: loader
        parent: indexRoot
        anchors.fill: parent
        active:false
        source:"Teachers/Index.qml"
    }
    ListModel {
        id:listmodel
        // TODO
        //ListElement {
        //    identity: "01"
        //    image: "../../../resources/tests/热门老师 红色.jpg"
        //}
        //ListElement {
        //    identity: "02"
        //    image: "../../../resources/tests/热门老师 蓝色.jpg"
        //}
    }
    Request.TeacherGroupsFetcher {
        id:teacherGroupsFetcher
        onOk: {
            for(var i=0; i < groups.length; i++)
            {
                listmodel.append(groups[i])
            }
        }
    }
}
